import {
    reqCategoryList,
    reqBannerList,
    reqFloorList,
} from "@/api"
export default {
    actions: {
        async categoryList({commit}) {
          let result = await reqCategoryList()
            if(result.code == 200) {
                commit('CATEGORYLIST',result.data)
            } 
        },
        async bannerList({commit}) {
            let result = await reqBannerList() 
            if(result.code == 200) {
               commit('BANNERLIST',result.data)
            }
        },
        // 获取MOCK中的floor图片数据
        async floorList({commit}) {
            let result = await reqFloorList() 
            if(result.code == 200) {
                commit('FLOORLIST',result.data)
            }
        }
    },
    // 唯一操作state的函数
    mutations: {
        CATEGORYLIST(state,categoryList) {
            state.categoryList = categoryList
        },
        BANNERLIST(state,bannerList) {
            state.bannerList = bannerList
        },
        FLOORLIST(state,floorList) {
            state.floorList = floorList
        }
    },
    // 用于存储数据的地方
    state: {
        categoryList:[],
        bannerList:[],
        floorList:[]
    },
    // 为简化数据而生
    getters: {

    }
}